# compiladores
CC = gcc
ASMC = nasm

# compile-time flags
CFLAGS = -Wall
ASMFLAGS = -t -f coff

# source files
CSRCS = codepage.c sprite.c video-text.c video-graphics.c GQueue.c queue.c music.c score.c rtc.c timer.c ints.c kbc.c util.c play.c Tabuleiro.c menu.c game.c main.c
ASMSRCS = mouse_handler.asm kbd_isr.asm ints_asm.asm

# object files
OBJS = $(CSRCS:.c=.o) $(ASMSRCS:.asm=.o)

# ficheiro executavel
MAIN = bejeweled.exe

all: $(MAIN)
	@echo Tudo Compilado.

$(MAIN): $(OBJS) 
	ar cr liblcom.a $(OBJS)
	$(CC) $(CFLAGS) liblcom.a -o $(MAIN)


# regras de compilacao
%_handler.o: %_handler.asm
	$(ASMC) $(ASMFLAGS) $< -o $@
	
%_isr.o: %_isr.asm
	$(ASMC) $(ASMFLAGS) $< -o $@
	
%_asm.o: %_asm.asm
	$(ASMC) $(ASMFLAGS) $< -o $@

%.o: %.c
	$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
	
clean:
	$(RM) $(OBJS) $(MAIN)
	rm liblcom.a
	
rebuild:
	make clean
	make all
